This forum is closed to new posts and
responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:
Ok the issue is not related to MKDIR. Appears to be related to DIR$.
I had some spare time, so here is what I did.
1. Cleaned up your code to a much smaller sample.
2. Ran it and deleted the directories from the command prompt. Worked fine.
3. Ran it twice, as the logic is different the second time. Attempting to delete the directories the second last in the tree could not be removed (eg. "c:\a\b\c\d" directory c could not be removed).
4. Tested it a few times on different directory structures and confirmed it is related to the second last directory.
5. Moved the DIR$ out of the IF conditional statements to determine if they are connected. Could still reproduce the issue.
6. Now that I know the issue is related to DIR$ I checked for existing SPRs. I found JDYU6679FJ. this is a crash issue (which turned out not to be an issue). Not directly related to this issue, but mentioned that if DIR$ is called with parameters the CAPI code is put into a loop holding the directory. It is only returned if an error condition happens.
7. To test this I added a line at the end of the code to do DIR$("C:\temp"). As it has no parameters it should break the loop. Testing with this I was no longer able to recreate the issue.
Created SPR SODY85SM84 which details this issue so development can investigate further. I will do up a tech note later on it.
Here is the sample code if your interested. Hope all this helps.
--------
Option Public
Option Declare
Const ATTR_DIRECTORY = 16
Sub Initialize()
Const testDirectory = "c:\temp\simon\11\22\33\" ' requires \ at the end of the string or will fail.
createDirs(testDirectory)
End Sub
Private Function createDirs(path As String) As Boolean
On Error GoTo CP_DOH
Dim drive As String
Dim orgDir As String
Dim part As String
Dim rest As String
Dim ndx As Long
Dim first As Boolean
Dim dirCheck As string
If(dirCheck = "" ) Then
Print |- Mkdir |+part
MkDir(part)
Else
Print |- Reuse |+part
End If
End If
ndx=InStr(rest, "\")
Wend
' This line will stop the locking from occurring.
' Appears to be related to SPR JDYU6679FJ
' ***********************************************
' dirCheck = Dir$("c:\temp") ' Force without parameters
CP_DONE:
If(drive<>"") Then
ChDrive drive
End If
' return to original directory.
ChDir orgDir
Exit Function
CP_DOH:
createDirs=False
print | line | & Erl & | of createDirs: "|+Error$+|"|
Resume CP_DONE
End Function
Feedback response number WEBB85SMUW created by ~Rex Pretoolitoden on 05/25/2010